﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Global.Class.Library;
using DataAccessLayer;

namespace PresentationLayer
{
    public partial class PublicApplicationLogon : Form
    {
        public PublicApplicationLogon()
        {
            InitializeComponent();
        }

        private void PublicApplicationLogon_Load(object sender, EventArgs e)
        {
            try
            {
                //DataTable dataTable = ADODatabase.GetDataTable("SELECT * FROM ListFillingLineName");
                //this.comboBoxFillingLineID.DataSource = dataTable;
                //this.comboBoxFillingLineID.ValueMember = "FillingLineID";
                //this.comboBoxFillingLineID.DisplayMember = "FillingLineName";

                //if (dataTable.Rows.Count > 0) this.comboBoxFillingLineID.SelectedValue = dataTable.Rows[0]["LastLogonFillingLineID"];

                this.comboBoxFillingLineID.Text = Environment.UserName;
            }
            catch (Exception exception)
            {
                GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);
            }
        }

        private void labelFillingLineID_DoubleClick(object sender, EventArgs e)
        {
            this.comboBoxFillingLineID.Enabled = true;
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {

                GlobalVariables.shouldRestoreProcedure = this.checkBoxShouldRestoreProcedure.Checked ;

                //if (this.comboBoxFillingLineID.SelectedIndex < 0) throw new System.ArgumentException("Please select a filling line before try again.");
                //GlobalVariables.FillingLineID = (GlobalVariables.FillingLine)this.comboBoxFillingLineID.SelectedValue;
                //GlobalVariables.FillingLineName = (string)((DataRowView)this.comboBoxFillingLineID.SelectedItem)["FillingLineName"] ;

                //ADODatabase.ExecuteNonQuery("UPDATE ListFillingLineName SET LastLogonFillingLineID = " + (int)GlobalVariables.FillingLineID);

            }
            catch (Exception exception)
            {
                GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);

                this.DialogResult = DialogResult.None;
            }
        }

        private void labelFillingLineID_Click(object sender, EventArgs e)
        {

        }

    }
}
